'''
author:chuandong Lv
#2019 年9 月18日
'''

# coding=utf-8
import numpy as np
import tensorflow as tf
import random
import os
import cv2
import glob
import time
# import os
# os.environ["CUDA_VISIBLE_DEVICES"] = "-1"   #注释掉就是使用cpu,不注释就是使用gpu

def read_image():
    file_name1=os.listdir('data_faces')
    # print(file_name1)
    data_train=[]
    data_test=[]
    x_train1=[]
    y_train1=[]
    x_train2=[]
    y_train2=[]
    for k in range(len(file_name1)):
    	# file_name2=os.listdir('data_faces/'+file_name1[k])
    	# print(file_name2)
    	data=[cv2.imread('data_faces/'+file_name1[k]+'/'+str(i)+'.pgm',0) for i in range(1,11)]#是每个s里面的图像矩阵的集合
    	# print(data)
    	choose=random.sample(range(10),5)#随机选择5个作为训练
    	data_train.extend([data[i].ravel() for i in range(10) if i in choose])
    	# print(data_train)
    	data_test.extend([data[i],ravel() for i in range(10) if i not in choose])


read_image()